package com.second.app.thread.interrupt;

/**
 * @Author GYZ
 * <pre>
 *
 * </pre>
 */
public class MyThread extends Thread {
    @Override
    public void run() {
        try {
            for (int i = 0; i < 500000; i++) {
                if(this.isInterrupted()){
                    System.out.println("已经是停止状态了！我要退出了!");
                    throw new InterruptedException();
                }
                System.out.println("线程名称："+Thread.currentThread().getName()+"，打印i=" + (i + 1));
            }
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
